//
//  LHRecommendCityHomePageCollectionViewCell.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendCityHomePageCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface LHRecommendCityHomePageCollectionViewCell ()

@property (nonatomic, retain) UIImageView *sightPic;
@property (nonatomic, retain) UILabel *sightName;

@end

@implementation LHRecommendCityHomePageCollectionViewCell


- (void)dealloc
{
    [_sightPic release];
    [_sightName release];
    [super dealloc];
    
}

/**
 *  初始化 创建控件
 */

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        // 热门目的地图片
        self.sightPic = [[UIImageView alloc] init];
        
        _sightPic.backgroundColor = [UIColor colorWithRed:0.885 green:0.146 blue:0.590 alpha:1.000];
        
        self.sightPic.layer.cornerRadius = 5;
        self.sightPic.clipsToBounds = YES;
        
        [self.contentView addSubview:_sightPic];
        
        [_sightPic release];
        
        // 热门目的地名称
        self.sightName = [[UILabel alloc] init];
        
        [_sightName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:10]];
        
        [_sightName setShadowColor:[UIColor blackColor]];
        
        [_sightName setShadowOffset:CGSizeMake(1, 0)];
        
        [_sightPic addSubview:_sightName];
        
        [_sightName release];
        
    }
    
    
    return self;
}

/**
 *  控件布局信息
 */

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _sightPic.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    _sightName.frame = CGRectMake(10, self.contentView.frame.size.width - 30, 90, 20);
    
    
    
}

/**
 *  重写setter方法
 */

- (void)setPopularSight:(LHRecommendCityHomePageModel *)popularSight
{
    if (_popularSight != popularSight) {
        
        [_popularSight release];
        
        _popularSight = [popularSight retain];
    }
    
    [_sightPic sd_setImageWithURL:[NSURL URLWithString:popularSight.cover_s] placeholderImage:[UIImage imageNamed:@"word4"]];
    
    _sightName.text = popularSight.name;
    [ _sightName setFont:[UIFont systemFontOfSize:11]];
    [_sightName setTextColor:[UIColor whiteColor]];
    
    
}




@end
